
// The Heresiarch him/itself ------------------------------------------------

ACTOR Heresiarch native
{
	Health 5000
	Painchance 10
	Speed 16
	Radius 40
	Height 110
	Mass 500
	Damage 9
	Monster
	+FLOORCLIP
	+BOSS
	+DONTMORPH
	+NOTARGET
	+NOICEDEATH
	+DEFLECT
	+NOBLOOD
	SeeSound "SorcererSight"
	PainSound "SorcererPain"
	DeathSound "SorcererDeathScream"
	ActiveSound "SorcererActive"
	Obituary "$OB_HERESIARCH"
	
	action native A_SorcSpinBalls();
	action native A_SpeedBalls();
	action native A_SorcBossAttack();
	action native A_SpawnFizzle();
	
	States
	{
	Spawn:
		SORC A 3
		SORC A 2 A_SorcSpinBalls
	Idle:
		SORC A 10 A_Look
		Wait
	See:
		SORC ABCD 5 A_Chase
		Loop
	Pain:
		SORC G 8
		SORC G 8 A_Pain
		Goto See
	Missile:
		SORC F 6 Bright A_FaceTarget
		SORC F 6 Bright A_SpeedBalls
		SORC F 6 Bright A_FaceTarget
		Wait
	Attack1:
		SORC E 6 Bright
		SORC E 6 Bright A_SpawnFizzle
		SORC E 5 Bright A_FaceTarget
		Goto Attack1+1
	Attack2:
		SORC E 2 Bright
		SORC E 2 Bright A_SorcBossAttack
		Goto See
	Death:
		SORC H 5 Bright
		SORC I 5 Bright A_FaceTarget
		SORC J 5 Bright A_Scream
		SORC KLMNOPQRST 5 Bright
		SORC U 5 Bright A_NoBlocking
		SORC VWXY 5 Bright
		SORC Z -1 Bright
		Stop
	}
}

// Base class for the balls flying around the Heresiarch's head -------------

ACTOR SorcBall native
{
	Speed 10
	Radius 5
	Height 5
	Projectile
	-ACTIVATEIMPACT
	-ACTIVATEPCROSS
	+FULLVOLDEATH
	+CANBOUNCEWATER
	+NOWALLBOUNCESND
	BounceType "HexenCompat"
	SeeSound "SorcererBallBounce"
	DeathSound "SorcererBigBallExplode"

	action native A_SorcBallOrbit();
	action native A_SorcBallPop();
	action native A_BounceCheck ();
}

// First ball (purple) - fires projectiles ----------------------------------

ACTOR SorcBall1 : SorcBall native
{
	States
	{
	Spawn:
		SBMP ABCDEFGHIJKLMNOP 2 A_SorcBallOrbit
		Loop
	Pain:
		SBMP A 5 A_SorcBallPop
		SBMP B 2 A_BounceCheck
		Wait
	Death:
		SBS4 D 0 A_ChangeFlag("NOBOUNCESOUND", 1)
		SBS4 D 5 A_Explode(255,255)
		SBS4 E 5
		SBS4 FGH 6
		Stop
	}
}


// Second ball (blue) - generates the shield --------------------------------

ACTOR SorcBall2 : SorcBall native
{
	States
	{
	Spawn:
		SBMB ABCDEFGHIJKLMNOP 2 A_SorcBallOrbit
		Loop
	Pain:
		SBMB A 5 A_SorcBallPop
		SBMB B 2 A_BounceCheck
		Wait
	Death:
		SBS4 D 0 A_ChangeFlag("NOBOUNCESOUND", 1)
		SBS3 D 5 A_Explode(255,255)
		SBS3 E 5
		SBS3 FGH 6
		Stop
	}
}

// Third ball (green) - summons Bishops -------------------------------------

ACTOR SorcBall3 : SorcBall native
{
	States
	{
	Spawn:
		SBMG ABCDEFGHIJKLMNOP 2 A_SorcBallOrbit
		Loop
	Pain:
		SBMG A 5 A_SorcBallPop
		SBMG B 2 A_BounceCheck
		Wait
	Death:
		SBS4 D 0 A_ChangeFlag("NOBOUNCESOUND", 1)
		SBS3 D 5 A_Explode(255,255)
		SBS3 E 5
		SBS3 FGH 6
		Stop
	}
}


// Sorcerer spell 1 (The burning, bouncing head thing) ----------------------

ACTOR SorcFX1
{
	Speed 7
	Radius 5
	Height 5
	Projectile
	-ACTIVATEIMPACT
	-ACTIVATEPCROSS
	-NOGRAVITY
	+FULLVOLDEATH
	+CANBOUNCEWATER
	+NOWALLBOUNCESND
	BounceFactor 1.0
	+HEXENBOUNCE
	SeeSound "SorcererBallBounce"
	DeathSound "SorcererHeadScream"

	action native A_SorcFX1Seek();

	States
	{
	Spawn:
		SBS1 A 2 Bright
		SBS1 BCD 3 Bright A_SorcFX1Seek
		Loop
	Death:
		FHFX S 2 Bright A_Explode(30, 128)
		FHFX SS 6 Bright
		Stop
	}
}


// Sorcerer spell 2 (The visible part of the shield) ------------------------

ACTOR SorcFX2
{
	Speed 15
	Radius 5
	Height 5
	+NOBLOCKMAP
	+NOGRAVITY
	+NOTELEPORT

	action native A_SorcFX2Split();
	action native A_SorcFX2Orbit ();

	states
	{
	Spawn:
		SBS2 A 3 Bright A_SorcFX2Split
		Loop
	Orbit:
		SBS2 A 2 Bright
		SBS2 BCDEFGHIJKLMNOPA 2 Bright A_SorcFX2Orbit
		Goto Orbit+1
	Death:
		SBS2 A 10
		Stop
	}
}

// The translucent trail behind SorcFX2 -------------------------------------

ACTOR SorcFX2T1 : SorcFX2
{
	RenderStyle Translucent
	Alpha 0.4
	States
	{
	Spawn:
		Goto Death
	}
}


// Sorcerer spell 3 (The Bishop spawner) ------------------------------------

ACTOR SorcFX3
{
	Speed 15
	Radius 22
	Height 65
	+NOBLOCKMAP
	+MISSILE
	+NOTELEPORT
	SeeSound "SorcererBishopSpawn"

	action native A_SpawnBishop();
	action native A_SorcererBishopEntry();

	States
	{
	Spawn:
		SBS3 ABC 2 Bright
		Loop
	Death:
		SBS3 A 4 Bright
		BISH P 4 A_SorcererBishopEntry
		BISH ON 4
		BISH MLKJIH 3
		BISH G 3 A_SpawnBishop
		Stop
	}
}


// The Bishop spawner's explosion animation ---------------------------------

ACTOR SorcFX3Explosion
{
	+NOBLOCKMAP
	+NOGRAVITY
	+NOTELEPORT
	RenderStyle Translucent
	Alpha 0.4
	States
	{
	Spawn:
		SBS3 DEFGH 3
		Stop
	}
}


// Sorcerer spell 4 (The purple projectile) ---------------------------------

ACTOR SorcFX4
{
	Speed 12
	Radius 10
	Height 10
	Projectile
	-ACTIVATEIMPACT
	-ACTIVATEPCROSS
	DeathSound "SorcererBallExplode"

	action native A_SorcFX4Check();

	States
	{
	Spawn:
		SBS4 ABC 2 Bright A_SorcFX4Check
		Loop
	Death:
		SBS4 D 2 Bright
		SBS4 E 2 Bright A_Explode(20, 128)
		SBS4 FGH 2 Bright
		Stop
	}
}


// Spark that appears when shooting SorcFX4 ---------------------------------

ACTOR SorcSpark1
{
	Radius 5
	Height 5
	Gravity 0.125
	+NOBLOCKMAP
	+DROPOFF
	+NOTELEPORT
	RenderStyle Add
	States
	{
	Spawn:
		SBFX ABCDEFG 4 Bright
		Stop
	}
}
